package com.xmd.red.web;

import com.xmd.red.config.WxConfig;
import com.xmd.red.service.RedPacketService;
import com.xmd.red.utils.AESSecurityUtil;
import com.xmd.red.utils.CommonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by superbone on 2016/10/30.
 */
@RestController
@RequestMapping("/red")
public class RedController {




    @Resource
    private RedPacketService service;

    @RequestMapping("/send")
    public CommonResult send(String params, HttpServletRequest request){


        String clientIp = request.getRemoteAddr();
        String serverIp = request.getLocalAddr();
        try{
            return service.send(params,clientIp,serverIp);
        }catch (Exception e){
            return CommonResult.serverError("服务器错误");
        }


    }

    @RequestMapping("/confirm")
    public CommonResult confirm(String params){
        try{
            return service.confirm(params);
        }catch (Exception e){
            return CommonResult.serverError("服务器错误");
        }

    }

    @RequestMapping("/feedback")
    public CommonResult feedback(String params){

        try{
            return service.feedback(params);
        }catch (Exception e){
            return CommonResult.serverError("服务器错误");
        }

    }

    @RequestMapping("/test")
    public CommonResult test(String params){
        try{
            return service.test(params);
        }catch (Exception e){
            return CommonResult.serverError("服务器错误");
        }
    }

    @RequestMapping("/import")
    public CommonResult importData(){
        return service.importData();
    }
}
